<?php
/**
 * 

 */


class db_gonglue_cron_topic extends db_base
{
	
 
	var $table_name = "gonglue_cron_topic";
	
	function db_gonglue_cron_topic()
	{
		parent::db_base();
	}
	
	function admin_get_one_by_id($id)
	{
		$id = intval($id);
		
		$where = "id = $id";
		$list = $this->get_alllist($this->table_name,$p,$pcount,"",$where);
		
		return $list[0];
	}
	
	
	function admin_get_list_by_search($p=1,$pcount=20,$topic_id="")
	{
		$p = intval($p);
		$pcount = intval($pcount);
		$topic_id = intval($topic_id);
		
		$ary_where =  array();
		if($topic_id)
		{
			$ary_where[] = "topic_id = $topic_id";
		}
		
		$ary_where[] = "status = 1";
		
		
		$where = join(" and ",$ary_where);
		$list = $this->get_alllist($this->table_name,$p,$pcount,"",$where);
		
		return $list;
	}
	
	
	function admin_get_count_by_search($topic_id="")
	{
		
		$topic_id = intval($topic_id);
		
		$ary_where =  array();
		if($topic_id)
		{
			$ary_where[] = "topic_id = $topic_id";
		}
		
		$ary_where[] = "status = 1";
		
		
		$where = join(" and ",$ary_where);
		$list = $this->get_listcount($this->table_name,$where);
		
		return $list;
	}
	
	
	function admin_insert_gonglue_cron_topic($topic_id,$url,$get_type,$content_type)
	{
		// 插入数据
		$ary = array();

		$ary["topic_id"] = $topic_id;
		$ary["url"] = $url;
		$ary["get_type"] = $get_type;
		$ary["content_type"] = $content_type;
		
		$ary["status"] = 1;
		
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
		
		
		$ret = $this->insert($this->table_name, $ary);
		if ($ret)
		{
			/*$memcache = mem_cache::get_instance();
			$memcache->delete($key);*/
		}
		else
		{
			return false;
		}


		return $this->get_lastinsertid();
	}
	
	
	function admin_update_gonglue_cron_topic($id,$topic_id,$url,$get_type,$content_type)
	{
		$id = intval($id);
		// 插入数据
		$ary = array();

		$ary["topic_id"] = $topic_id;
		$ary["url"] = $url;
		$ary["get_type"] = $get_type;
		$ary["content_type"] = $content_type;
		$where = "id = $id";
		
		
		
		$ret = $this->update($this->table_name, $ary,$where);
		if ($ret)
		{
			/*$memcache = mem_cache::get_instance();
			$memcache->delete($key);*/
		}
		else
		{
			return false;
		}


		return $ret;
	}
	
	
	
	function admin_del_gonglue_cron_topic($id)
	{
		$id = intval($id);
		
		// 插入数据
		$ary = array();
		$ary["status"] = 0;
		
		$where = "id = $id";
		
		
		$ret = $this->update($this->table_name, $ary,$where);
		if ($ret)
		{
			/*$memcache = mem_cache::get_instance();
			$memcache->delete($key);*/
		}
		else
		{
			return false;
		}


		return $ret;
	}
	
	
	
	
	
	
	
		/**
	 * cron 获取food_tag
	 */
	function cron_get_gonglue_topic_count($start_id)
	{
		global $config;
		
		$start_id = intval($start_id);
		
		
		$where=" id > $start_id  and  status = 1 " ;
		$data = $this->get_listcount($this->table_name, $where);
		
		return $data;
	}
	

		/**
	 * cron 获取food_tag
	 */
	function cron_get_gonglue_topic_list($p,$pcount,$start_id)
	{
		global $config;
		
		$start_id = intval($start_id);
		$where=" id > $start_id  and  status = 1 " ;
		$data = $this->get_alllist($this->table_name,$p,$pcount,"id" , $where);
		
		return $data;
	}
	
	function cron_update_by_id($id,$cron_get_time)
	{
		if($cron_get_time)$ary["cron_get_time"] = $cron_get_time; 
		$where=" id=  $id " ;
		
		$data = $this->update($this->table_name,$ary , $where);
		
		return $data;
	}
	
	

}
